package network;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:24097
 * Date:2025-10-13
 * Time:21:37
 */
public class UpdDictServer extends UdpEchoServer{
    private HashMap<String,String>dict=new HashMap<>();
    public UpdDictServer(int port) throws SocketException {
        super(port);
        //初始化词典
        dict.put("小猫","cat");
        dict.put("小狗","dog");
        dict.put("小兔子","rabit");
        dict.put("小鸭子","duck");
    }
    @Override
    public String process(String request){
        //查字典
        return dict.getOrDefault(request,"未找到词条");
    }

    public static void main(String[] args) throws IOException {
        UpdDictServer server=new UpdDictServer(9090);
        server.start();
    }

}
